package com.kuangstudy.collection.list;

import java.util.Enumeration;
import java.util.Vector;

/**
 * ClassName: Demo5
 * date: 2021/07/12 16:59:16
 *
 * @author zlk
 */
public class Demo5 {
    /**
     * vector 线程安全，已经不用了
     * @param args
     */
    public static void main(String[] args) {
        /*创建集合*/
        Vector vector = new Vector<>();
        /*添加元素*/
        vector.add("草莓");
        vector.add("苹果");
        vector.add("西瓜");
        System.out.println(vector.size());
        System.out.println(vector);
//        vector.remove("西瓜");
//        vector.clear();
        /*枚举器遍历*/
        Enumeration elements = vector.elements();
        while (elements.hasMoreElements()) {
            System.out.println(elements.nextElement());
        }
        System.out.println(vector.contains("西瓜"));
        System.out.println(vector.firstElement());
    }
}
